<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>arguments获取设置非行间样式</title>
		<style>
			#div1 {
				width: 200px;
				height: 200px;
				background: red;
			}
		</style>
	</head>

	<body>
		<div id="div1" </div>
			<script>
				window.onload = function() {
					var div1 = document.getElementById("div1");
					alert(getstyle(div1, "width"));
					getstyle(div1, "background", "blue")
				}

				function getstyle(obj, name, value) {
					if(arguments.length == 2) {
						if(obj.currenstyle){
							return obj.currenStyle()[name];
						}else{
							return getComputedStyle(obj,false)[name];
						}

					} else if(arguments.length == 3){
						obj.style[name]=value;
					}else{
						alter("函数调用参数有误！")
					}
				}
			</script>
	</body>

</html>